package com.ruoyi.produce.process.datacollection.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.produce.process.datacollection.domain.DataCollectionCond;
import com.ruoyi.produce.process.datacollection.domain.DataCollection;
import com.ruoyi.produce.process.datacollection.domain.RealTimeCapacity;
import com.ruoyi.produce.process.datacollection.service.IDataCollectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 生产数据
 * 视图层
 */
@RestController
@RequestMapping("/produce/data/collection")
@Api(value = "生产数据信息模块", tags = "生产数据接口")
public class DataCollectionController extends BaseController {
    @Autowired
    private IDataCollectionService dataCollectionService;

    /**
     * 根据搜索条件所有生产数据记录
     * @param cond 搜索条件
     * @return
     */
    @ApiOperation(value = "获取生产数据列表",notes = "查询所有生产数据信息")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody DataCollectionCond cond) {
        startPage();
        List<DataCollection> dataCollectionList = dataCollectionService.selectDataCollectionList(cond);
        return getDataTable(dataCollectionList);
    }

    /**
     * 删除生产数据记录
     * 仅修改删除标志
     * @param dataCollection
     * @return
     */
    @ApiOperation(value = "删除生产数据记录", notes = "删除生产数据记录,仅删除标志位")
    @PostMapping("/delete")
    public AjaxResult delete(@RequestBody DataCollection dataCollection) {
        return toAjax(dataCollectionService.updateDataCollectionDeleteFlag(dataCollection));
    }

    /**
     * 查询实时产能
     * @param cond
     * @return
     */
    @ApiOperation("查询实时产能")
    @PostMapping("/capacity")
    public TableDataInfo searchRealTimeCapacity(@RequestBody DataCollectionCond cond) {
        startPage();
        List<RealTimeCapacity> realTimeCapacityList = dataCollectionService.searchRealTimeCapacity(cond);
        return getDataTable(realTimeCapacityList);
    }
}
